package edu.kit.los.event;

import java.io.Serializable;

/**
 * @author Felix Kiechle, Benedikt Fuss  AIFB@BKIT
 * Bietet einen Konstruktor, um ein Event als Standardevent zu parsen .
 * Dies wird für die einheitliche Überführung in RDF verwendet. 
 */
public class StandardEvent implements edu.kit.los.event.Event, Serializable{

	/**
	 * ID für Serialiserung
	 */
	private static final long serialVersionUID = 1L;
	private double geoLat;
	private double geoLong;
	private String starttime;
	private String stoptime;
	private String eventUrl;
	private String title;
	private String description;
	private String venueName;
	private String publisher;
	
	/**
	 * Konstruktor für Standard-Event
	 * @param lat Latitude
	 * @param longi Longitude
	 * @param stDate Startdatum
	 * @param enDate Enddatum
	 * @param eventUrl URL (HTML-Seite) des Anbieters zum Event
	 * @param title Titel
	 * @param description Beschreibung
	 * @param publisher Link zum Anbieter
	 * @param venueName Beschreibung des Ortes
	 */
	public StandardEvent(double lat, double longi, String stDate, String enDate, String eventUrl, String title, String description, String publisher, String venueName){
		this.stoptime = enDate;
		this.starttime = stDate;
		this.title = title;
		this.description = description;
		this.venueName = venueName;
		this.publisher = publisher;
		this.eventUrl = eventUrl;
		this.geoLat = lat;
		this.geoLong = longi;
	}

	/**
	 * Konstruktor, um aus einem FacebookEvent ein StandardEvent zu konstruiern
	 * @param FacebookEvent event
	 */
	public StandardEvent(FacebookEvent event) {
		this.stoptime = (event.getStopTime() == null) ? null : event.getStopTime().toString();
		this.starttime = (event.getStartTime() == null) ? null: event.getStartTime().toString();
		this.title = (event.getTitle() == null) ? null : event.getTitle();
		this.description = (event.getDescription() == null) ? null: event.getDescription();
		this.venueName = (event.getVenueName() == null) ? null: event.getVenueName();
		this.publisher = "http://www.facebook.com";
		this.eventUrl = "http://www.facebook.com/events/" + event.getId();
		this.geoLat = event.getGeoLat();
		this.geoLong = event.getGeoLong();
	
	}

	/**
	 * Konstruktor, um aus einem EventFul-Event ein StandardEvent zu konstruiern
	 * @param EventFulEvent event
	 */
	public StandardEvent(com.evdb.javaapi.data.Event event) {
		this.stoptime = (event.getStopTime() == null) ? null : event.getStopTime().toString();
		this.starttime = (event.getStartTime() == null) ? null : event.getStartTime().toString();
		this.title = (event.getTitle().equals(null)) ? null : event.getTitle();
		this.description = (event.getDescription().equals(null)) ? null : event.getDescription();
		this.venueName = (event.getVenueName().equals(null)) ? null : event.getVenueName();
		if (event.getSeid().equals(null)){
			this.eventUrl = null;
		}
		else{
			this.eventUrl =  "http://eventful.com/"+event.getSeid(); 
		}		
		this.publisher = "http://eventful.com";
		this.geoLat = event.getVenueLatitude();
		this.geoLong = event.getVenueLongitude();

	}

	
	/**
	 * Konstruktor, um aus einem UpcomingEvent ein StandardEvent zu konstruiern
	 * @param UpcomingEvent event
	 */
	public StandardEvent(upcoming.client.Event event) {
		this.stoptime = (event.getEndDate() == null) ? null : event.getEndDate().getTime().toString();
		this.starttime = (event.getStartDate() == null) ? null : event.getStartDate().getTime().toString();
		this.title = (event.getName() == null ) ? null : event.getName();
		this.description = (event.getDescription()== null) ? null : event.getDescription();
//		String venueName = (event.getVenueAddress().equals(null)) ? "unbekannt" : event.getVenueAddress();
		this.venueName = (event.getVenueName().equals(null)) ? null : event.getVenueName();
		
		this.eventUrl = null;
		String id = event.getId();
		if(id != null){
			this.eventUrl = "http://upcoming.yahoo.com/event/"+id;
		}
		this.publisher = "http://upcoming.yahoo.com";
		this.geoLat = Double.parseDouble(event.getLatitude());
		this.geoLong = Double.parseDouble(event.getLongitude());
	}

	
	public String toString(){
		StringBuilder sb = new StringBuilder();
		sb.append("Title: "+title);
		sb.append("\n");
		sb.append("\n");
		sb.append("Starttime: "+starttime.toString());
		sb.append("\n");
		sb.append("Stoptime: "+stoptime.toString());
		sb.append("\n");
		sb.append("Description: "+description);
		sb.append("\n");
		sb.append("Title: "+title);
		sb.append("\n");
		return sb.toString();
	}

	public String getTitle() {
		return title;
	}

	public String getDescription() {
		return description;
	}

	public String getVenueName() {
		return venueName;
	}

	public double getGeoLat() {
		return geoLat;
	}

	public double getGeoLong() {
		return geoLong;
	}

	public String getStartTime() {
		return starttime;
	}

	public String getStopTime() {
		return stoptime;
	}

	public String getEventUrl() {
		return eventUrl;
	}

	public String getPublisher() {
		return publisher;
	}
}
